package conMgr.model.tests;

import static org.junit.Assert.*;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.junit.Test;

import conMgr.model.Conference;
import conMgr.model.Paper;
import conMgr.model.Review;
import conMgr.model.User;
import conMgr.model.UserType;

public class ReviewTest {

	@Test
	public void testReview() throws ParseException {
		DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 
		Date date_1	=	(Date)formatter.parse("2012-12-12");
		Date date_2	=	(Date)formatter.parse("2012-12-15");
		Date date_3	=	(Date)formatter.parse("2012-12-17");
		Date date_4	=	(Date)formatter.parse("2012-12-19");
		User user_1 = new User("Bob", "Bob@mail.ru", UserType.REVIEWER);
		Conference conf_1 = new Conference("Conf 1", user_1, date_1	, date_2, date_3, date_4);
		Paper paper_1 = new Paper("Paper 1", user_1, conf_1, "Abstract", "category", "keywords", null);
		Review rev_1 = new Review(user_1,paper_1);
		
		assertEquals(user_1, rev_1.getReviewer());
		assertEquals(paper_1, rev_1.getPaper());
		assertEquals(UserType.REVIEWER, rev_1.getType());
		
	}
	
	@Test
	public void testSubmitToSubprogramChair() throws ParseException {
		
		Integer overallRating = 5;
		DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 
		Date date_1	=	(Date)formatter.parse("2012-12-12");
		Date date_2	=	(Date)formatter.parse("2012-12-15");
		Date date_3	=	(Date)formatter.parse("2012-12-17");
		Date date_4	=	(Date)formatter.parse("2012-12-19");
		User user_1 = new User("Bob", "Bob@mail.ru", UserType.REVIEWER);
		Conference conf_1 = new Conference("Conf 1", user_1, date_1	, date_2, date_3, date_4);
		Paper paper_1 = new Paper("Paper 1", user_1, conf_1, "Abstract", "category", "keywords", null);
		Review rev_1 = new Review(user_1,paper_1);
		List<Integer> ratings = new ArrayList<Integer>();
		ratings.add(7);
		ratings.add(3);
		rev_1.submitToSubprogramChair("commentsForAuthor", "commentsForSubprogramChair", ratings, overallRating);
		assertEquals("commentsForAuthor", rev_1.getcommentsForAuthor());
		assertEquals("commentsForSubprogramChair", rev_1.getcommentsForSpChair());
		assertEquals(ratings, rev_1.getRating());
		assertEquals(overallRating, rev_1.getOverallRatings());
		assertTrue(rev_1.getIsSubmitted());
		
		
	}

}
